package com.polytech.dao;

import java.util.Collection;
import java.util.HashMap;

import com.polytech.beans.Brand;
import com.polytech.beans.Model;

public class MemoryModelDao implements ModelDao {

	
	private HashMap<String, Model> models=new HashMap<String, Model>();
	private BrandDao brandDao;
	public MemoryModelDao(BrandDao brandDao) {
		this.brandDao=brandDao;
		insert(new Model("C4", 4, "essence",brandDao.select("Citroen") ));
		insert(new Model("C3", 4, "essence",brandDao.select("Citroen") ));
		insert(new Model("c3picasso", 6, "essence",brandDao.select("Citroen") ));
		insert(new Model("buggati", 2, "essence",brandDao.select("Bugatti") ));
		
		insert(new Model("A1", 4, "essence",brandDao.select("Audi") ));
		insert(new Model("A2", 4, "essence",brandDao.select("Audi") ));
		insert(new Model("A4", 4, "essence",brandDao.select("Audi") ));
		
		insert(new Model("Serie1", 4, "essence",brandDao.select("BMW") ));
		insert(new Model("X6", 4, "essence",brandDao.select("BMW") ));
		
		insert(new Model("giulietta", 4, "essence",brandDao.select("AlphaRomeo") ));
		insert(new Model("4C", 2, "essence",brandDao.select("AlphaRomeo") ));
		
	}
	
	
	@Override
	public void insert(Model model) {
		models.put(model.getName(), model);
		
	}

	@Override
	public Model select(String key) {
		
		return models.get(key);
	}

	@Override
	public void remove(Model model) {
		models.remove(model.getName());
	}


	@Override
	public Collection<Model> selectAll() {
		return models.values();
	}
	
}
